Schemacrawler logo

SchemaCrawler

Free database schema discovery and comprehension tool

SchemaCrawler MCP Server

Model Context Protocol (MCP) servers provide a way to allow specialized AI models to be connected directly to your development environment. MCP servers act as an intermediary to various AI tools, letting MCP clients communicate with custom models that are specialized for specific domains or tasks.

SchemaCrawler MCP Server leverages this protocol to provide advanced database schema analysis capabilities directly within your environment. This allows you to interact with your database using natural language, greatly simplifying tasks such as exploring database structure, understanding relationships between tables, and generating SQL queries.

Setting Up SchemaCrawler MCP Server

Prerequisites

Before using the SchemaCrawler MCP Server, you need:

  1. Docker and Docker Compose: Required to run the SchemaCrawler MCP Server container
  2. Visual Studio Code: For interacting with the MCP server

Starting the SchemaCrawler MCP Server

  1. Clone https://github.com/schemacrawler/SchemaCrawler-MCP-Client-Usage

  2. Make sure Docker is running on your system.

  3. Run the SchemaCrawler MCP Server using Docker Compose:

docker-compose -f schemacrawler-mcpserver.yaml up -d
  1. Verify the server is running by checking its health status:

Open a browser and navigate to http://localhost:8080/health

  1. Open the cloned project in Visual Studio Code. Visual Studio Code should automatically detect this configuration when you open the workspace.

  2. Open Visual Studio Code and access the chat feature (View > Command Palette > “Chat: Focus on Chat” or use the chat icon).

  3. Switch to “Agent” mode in the chat interface.

Sample Queries

You can interact with your database by asking natural language questions in the chat. Here are some examples:

Connecting to Your Own Database

By default, SchemaCrawler MCP Server connects to a sample SQLite database. To connect to your own database:

  1. Stop the currently running SchemaCrawler MCP Server:
docker-compose -f schemacrawler-mcpserver.yaml down -t0
  1. Edit the schemacrawler-mcpserver.yaml file to update the database connection details:
services:
  schemacrawler-mcpserver:
    # ... other configuration ...
    command: >
      --server YOUR_DATABASE_TYPE
      --host YOUR_HOST
      --port YOUR_PORT
      --database YOUR_DATABASE_NAME
      --user YOUR_USERNAME
      --password YOUR_PASSWORD
      --command mcpserver
      --info-level maximum
      --log-level INFO

Replace the placeholders with your actual database connection details: - YOUR_DATABASE_TYPE: The type of database (e.g., mysql, postgresql, sqlserver, oracle) - YOUR_HOST: The hostname or IP address of your database server - YOUR_PORT: The port number your database server is listening on - YOUR_DATABASE_NAME: The name of your database - YOUR_USERNAME: The username for connecting to your database - YOUR_PASSWORD: The password for connecting to your database

  1. Restart the SchemaCrawler MCP Server:
docker-compose -f schemacrawler-mcpserver.yaml up -d

Troubleshooting

Server Not Starting

Connection Issues

Visual Studio Code Not Connecting